<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title><s:text name="role.list.title"/></title>
	<%@ include file="/common/meta.jsp"%>
	<%@ include file="/common/common.jsp"%>

</head>
<body>
<div id="wrapper">
<div id="main_box">
	<div class="curmb"><s:text name="your.site.position"/>:<a href="${ctx}/main.action"><s:text name="homepage"/></a><span>></span><s:text name="role.title"/></div>
	<div class="listtit" id="listtit"><p><span><strong><s:text name="role.list.title"/></strong></span></p></div>
	<s:form action="role-list" id="search_form">
	<div class="searchbox">
		<table class="searchTable">
			<tbody id="searchTable">
				<tr>
					<td class="text"><label for="search" class="labelKeywords"><s:text name="key.words"/>:</label></td>
					<td class="input"><s:textfield name="role.keyword"  cssClass="txtsearch_long" maxlength="30"  ></s:textfield> </td>
					<td><label for="qry_activeStatus"><s:text name="role.activeStatus"/>: </label></td>
					<td>
						<s:select cssStyle="width:121px" list="isActive" name="role.active" listKey="dictionaryKey" listValue="dictionaryValue" headerKey="--" headerValue="请选择"/>
					</td>
					<td><input type="button" value="<s:text name="query"/>" class="btnsearch" id="search_btn"/></td>
				</tr>
				<tr>
					<td><label for=qry_startTime><s:text name="role.createTimeStart"/>: </label></td>
					<td>
					<input name="role.createTimeStart"  class="Wdate" id="qry_startTime" readonly="true"  value="<s:property value="%{formatDate(role.createTimeStart)}"/>"
							onFocus="WdatePicker({maxDate:'#F{$dp.$D(\'qry_endTime\')||\'2030-10-01\'}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})" type="text"/>
					
					<td><label for="qry_endTime"><s:text name="role.createTimeEnd"/> : </label></td>
					<td>
					<input name="role.createTimeEnd"  class="Wdate" id="qry_endTime" readonly="true"  value="<s:property value="%{formatDate(role.createTimeEnd)}"/>"
							onFocus="WdatePicker({minDate:'#F{$dp.$D(\'qry_startTime\')}',skin:'whyGreen',dateFmt:'yyyy-MM-dd HH:mm'})" type="text"/>
					
					</td>
				</tr>
			</tbody>
		</table>
		<div class="clear"></div>
	</div>
	<div class="listoperate">
		<span class="cssa"><input id="top_new_btn" type="button" value="<s:text name="new"/>" class="btnadd"/></span>
		<span>
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="top_anti_btn"/>
			<input type="button" value="<s:text name="disable"/>" class="btnlist2" id="top_disable_btn"/>
			<input type="button" value="<s:text name="enable"/>" class="btnlist2" id="top_enable_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="top_del_btn"/>
		</span>
	</div>
	<div class="listbox" id="listbox">
		<table class="listgrid" id="listbox">
			<tbody>
				<tr>
					<th><input type="checkbox" name="all" id="all_check"/></th>
					<th><s:text name="role.roleName"/></th>
					<th><s:text name="role.activeStatus"/></th>
					<th><s:text name="role.memo"/></th>
					<th><s:text name="role.admins"/></th>
					<th><s:text name="operate"/></th>
				</tr>
				<s:iterator value="page.result">
					<tr>
					<td><input type="checkbox" name="key" value="<s:property value="roleId"/>"/></td>
					<td><s:property value="roleName"/>&nbsp;</td>
					<td>
					    <s:if test="!activeStatus">
							<font color="red"><s:property value="%{getName(activeStatus,'IS_ACTIVE')}"/>&nbsp;</font>
					    </s:if>
					    <s:else>
					    	<s:property value="%{getName(activeStatus,'IS_ACTIVE')}"/>&nbsp;
					    </s:else>
					</td>
					<td class="left w30p"><s:property value="memo"/>&nbsp;</td>
					<td class="left"><a href="${ctx}/system/admin-list.action?admin.role.roleId=<s:property value="roleId"/>">
						<s:property value="%{getTwoAdmin(admins)}" escape="false"/>
					</a> </td>
						<td>
							<a href="#this" onclick="goEdit('role.roleId','<s:property value="roleId"/>')"><s:text name="edit"/></a><tt>|</tt>
						    <a href="#this" onclick="disableOrEnable('<s:property value="roleId"/>','<s:property value="%{getTurn(activeStatus,'IS_ACTIVE')}"/>')"><s:property value="%{getTurn(activeStatus,'IS_ACTIVE')}"/>&nbsp;</a><tt>|</tt>
						    <a href="#this" onclick="goDel('<s:property value="roleId"/>')"><s:text name="delete"/></a><tt>|</tt>
						    <a href="###" onclick="opercode('<s:property value="roleId"/>')"><s:text name="role.allocate"/> </a>
						</td>
					</tr>
				</s:iterator>
			</tbody>
		</table>
		<div class="listoperateb ">
			<div class="pager fr"><z:page numberNav="true" selectPageSize="true" input="true" id="ctrl"/></div>
		</div>
	</div>
	</s:form>
	<div class="listoperateb ">
		<span>
			<input type="button" value="<s:text name="anti-selection"/>" class="btnlist2" id="bottom_anti_btn"/>
			<input type="button" value="<s:text name="disable"/>" class="btnlist2" id="bottom_disable_btn" />
			<input type="button" value="<s:text name="enable"/>" class="btnlist2" id="bottom_endisable_btn"/>
			<input type="button" value="<s:text name="delete"/>" class="btnlist2" id="bottom_del_btn"/>
		</span>
	</div>
</div>
</div>
</body>
</html>
<script type="text/javascript" src="${ctx}/js/My97DatePicker/WdatePicker.js"></script>
<script type="text/javascript" defer="defer">
	actionName = "role";	
	confirmStr = "<s:text name="delete.confirm"/>";
	chiocenothing = "<s:text name="chiocenothing"/>";
	$(function(){
 		$("#top_new_btn").click(goNew);
 		$("#top_anti_btn").click(antiSelect);
 		$("#top_del_btn").click(doBatchDel);
 		$("#bottom_del_btn").click(doBatchDel);
 		$("#bottom_anti_btn").click(antiSelect);
		$("#search_btn").click(search);
		$("#all_check").click(selAll);
		$("#top_disable_btn").click(batchDisable);
		$("#bottom_disable_btn").click(batchDisable);
		$("#top_enable_btn").click(batchEnable);
		$("#bottom_endisable_btn").click(batchEnable);
	});
	
	function opercode(id){
		window.open("${ctx}/system/opercode-list.action?objectType=role&objectId="+id,"newwindow", "height=500, width=800, toolbar =no, menubar=no, scrollbars=yes, resizable=yes, location=no, status=no");
	}
	
	var g = function(D) {
		if ( D.indexOf(" ") == -1){
			return ( D.substring(0,1) === "#") ? document.getElementById(D.substring(1,D.length)) : document.getElementsByTagName(D);
		}
		else {
			var ary = D.split(" ");
			return g(ary[0]).getElementsByTagName(ary[1]);
		}
	};
	function inputvalue(){
		var d = g("#listbox input"), i = 0, j = d.length, str = "";
	    for ( ; i < j ; i ++ ) {
				str += (d[i].type == "checkbox" && d[i].id != "totalCheck" && d[i].checked == true ) ? d[i].value + "@" : "";
		};	
		return (str.slice(0,-1));
	};
	
	
	function disableOrEnable(id,action){
		var myDate=new Date();
		var sign="";
		if(action=='<s:text name="disable"/>'){
			sign='<s:text name="sureDisable"/>';
		}else{
			sign='<s:text name="sureEnable"/>';
		}
		if(confirm(sign)){
			document.location.href="${ctx}/system/role-disableorenable.action?role.roleId="+id;
		}
	}
	
	function  goDel(id){
		if(confirm('<s:text name="sureDelete"/>')){
			var obj={"role.roleId":id};
			$.post("${ctx}/system/role-delete.action",obj,function(data){
				alert(data);
				document.location.href="${ctx}/system/role-list.action";
			});
		}
	}
	
	function doBatchDel(){
		var ids=inputvalue();
		if(!ids){
			return;
		}
		if(confirm('<s:text name="sureDelete"/>')){
			var obj={"ids":ids};
			$.post("${ctx}/system/role-delete.action",obj,function(data){
				alert(data);
				document.location.href="${ctx}/system/role-list.action";
			});
		}
	}
	
	function batchDisable(){
		var ids=inputvalue();
		if(!ids){
			return;
		}
		if(confirm('<s:text name="sureDisable"/>')){
			document.location.href="${ctx}/system/role-activestatus.action?ids="+ids+"&role.activeStatus="+false;
		}
	}
	
	function batchEnable(){
		var ids=inputvalue();
		if(!ids){
			return;
		}
		if(confirm('<s:text name="sureEnable"/>')){
			document.location.href="${ctx}/system/role-activestatus.action?ids="+ids+"&role.activeStatus="+true;
		}
	}
	$(function(){
		if ($.browser.msie && ($.browser.version == "6.0") && !$.support.style) {
			$('#main_box').width($('#main_box').width()-25);
		}
	});
	</script>